<!DOCTYPE html>
<html lang="en">

<head>
 <meta charset="UTF-8">
 <meta name="viewport"
  content="width=device-width, initial-scale=1.0, minimum-scale=1,maximum-scale=1,user-scalable=no">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <title data-ch="恐龙探险" data-en="Dinosaur Adventure" class="document_title">恐龙探险</title>
 <script src="js/jquery-3.3.1.min.js"></script>
 <script src="js/common.js"></script>
 <script src="js/layer.js"></script>
 <script src="js/rem.js"></script>
 <script type="text/javascript">
  isLogin();
 </script>
 <link rel="stylesheet" href="css/common.css">
 <link rel="stylesheet" href="css/index.css">
</head>

<body>
 <!--头部-->
 <div class=" jui_top_bar">
  <a class="jui_top_left" href="javascript:history.back(-1)"><img src="icons/back.png"></a>
  <div class="jui_top_middle font_weight">添加银行资料</div>
 </div>
 <!-- 头部end -->
 <!-- 内容部分 -->
 <div class="reg_box jui_main padding_032">
  <!-- 银行列表部分 -->
  <div class="latout_mask bank_add_main border_radius05">
   <!-- 马来西亚银行列表 -->
   <div class="reg_list bank_add_list bank_select">
    <div class="reg_list_title f30 col_fff" data-ch="开户银行" data-en="Bank name">开户银行:</div>
    <img class="bank_choose_icon" src="./icons/down.png" alt="">
    <select class="bank_add_list_input" name="" id="bankName" style="width:100%; padding: 0 0.32rem;">
     <option value="Maybank">Maybank</option>
     <option value="Public">Public</option>
     <option value="RHB Bank">RHB Bank</option>
     <option value="Ambank">Ambank</option>
     <option value="CIMB Bank">CIMB Bank</option>
     <option value="UOB Bank Malaysia">UOB Bank Malaysia</option>
     <option value="Hong Leong Bank">Hong Leong Bank</option>
     <option value="Bank Rakyat">Bank Rakyat</option>
     <option value="OCBC Bank Malaysia">OCBC Bank Malaysia</option>
     <option value="HSBC Bank Malaysia">HSBC Bank Malaysia</option>
     <option value="Affin Bank">Affin Bank</option>
     <option value="Bank slam Malaysia">Bank slam Malaysia</option>
     <option value="Standard Chartered Bank">Standard Chartered Bank</option>
     <option value="CitiBank Malaysia">CitiBank Malaysia</option>
     <option value="Bank Simpanan Nasional">Bank Simpanan Nasional</option>
     <option value="Alliance Bank">Alliance Bank</option>
    </select>
   </div>
   <div class="reg_list bank_add_list">
    <div class="reg_list_title f30 col_fff" data-ch="银行账号" data-en="Bank account number">银行账号:</div>
    <input type="text" class="bank_add_list_input bank_num">
   </div>
   <div class="reg_list bank_add_list">
    <div class="reg_list_title f30 col_fff" data-ch="银行户口名称" data-en="Bank account holder name">银行户口名称:</div>
    <input type="text" class="bank_add_list_input bank_hu_name">
   </div>
   <div class="reg_list bank_add_list bank_add_list_last">
    <div class="reg_list_title f30 col_fff" data-ch="银行开户处" data-en="Bank branch">银行开户处:</div>
    <input type="text" class="bank_add_list_input bank_where">
   </div>
   <div class="zhuan_jirou_btn bank_add_btn col_fff border_radius05 text_center" data-ch="确认" data-en="Confirm">确认
   </div>
  </div>
  <!-- 银行列表部分end -->


  <script>
   $(function(){
    var isBank = localStorage.getItem("isBank");
    var language_type = localStorage.getItem("language_type");
    if(isBank == 0){
     $(".jui_top_middle").html(language_type == 1 ? '添加银行资料' : 'Fill in bank details')
    } else {
     $(".jui_top_middle").html(language_type == 1 ? '更改银行资料' : 'Change in bank details');
     // 获取默认银行资料信息
     var data = {
     uid: localStorage.getItem("u_id"),
     token: localStorage.getItem("token"),
     language_type: localStorage.getItem("language_type")
     }
     $.ajax({
      type: 'post',
      url: baseURL + '/index.php?m=user&c=config_setup',
      data: data,
      success: function success(data) {
       data = JSON.parse(data);
       is_login(data);
       if (data.code == 1) {
        $(".bank_num").attr("value",data.user.m_shou_account);
        $(".bank_hu_name").attr("value",data.user.m_shou_bank_name);
        $(".bank_where").attr("value",data.user.m_shou_bank);
       } else {
        box_timer(data.msg)
       }
      }
     })
    }

    $(".bank_add_btn").click(function(){
     // location.href = "bank_info.html"
     let bankName = $("#bankName").find("option:selected").attr("value"); // 开户银行
     let bankNum = $(".bank_num").val(); // 银行账号
     let banHuName = $(".bank_hu_name").val(); // 银行户口名称
     let bankWhere = $(".bank_where").val(); // 银行开户处
     if(!bankNum){
     box_timer(language_type == 1 ? '请输入银行账户' : 'Please enter bank account number')
     } else if(!banHuName){
     box_timer(language_type == 1 ? '请输入银行户口名称' : 'Please enter bank account holder name')
     } else if(!bankWhere){
     box_timer(language_type == 1 ? '请输入银行开户处' : 'Please enter bank branch')
     } else {
      var data = {
       uid: localStorage.getItem("u_id"),
       token: localStorage.getItem("token"),
       language_type: language_type,
       m_shou_bank_kai: bankName,
       m_shou_account: bankNum,
       m_shou_bank_name: banHuName,
       m_shou_bank: bankWhere
      }
      $.ajax({
       type: 'post',
       url: baseURL + '/index.php?m=user&c=setup_bank',
       data: data,
       success: function success(data){
        data = JSON.parse(data);
        is_login(data);
        box_timer(data.msg);
        if(data.code == 1){
         localStorage.setItem("isBank", '1')
         setTimeout(function(){
          window.history.go(-1) // 返回上一页
         },1500)
        }
       }
      })
     }
    })

    language();
    documentName()
   })
   
  </script>
 </div>
</body>

</html>